package com.zx._01_基础.浅拷贝and深拷贝.deep;


public class User implements Cloneable {

    private Integer id;

    private Name name;

    public User() {
    }

    public User(Integer id, Name name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Name getName() {
        return name;
    }

    public void setName(Name name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "User [id=" + id + ", name=" + name + "]";
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        User user = (User) super.clone();
        user.setName((Name) user.getName().clone());
        return user;
    }
}
